# kube插件安装
gc https://github.com/itowlson/spin-pluginify
cargo run -r -- --install

gc https://github.com/spinframework/spin-plugin-kube

make && make install

# rustup target add wasm32-wasi

# 创建应用
spin new --accept-defaults -t http-rust hello-rust
cd hello-rust

# 编译
spin build

# 推送镜像
docker login gitea.lntu.edu.cn
spin registry push gitea.lntu.edu.cn/youling/spin-js:v1

# docker login
spin registry push --build gitea.lntu.edu.cn/youling/hello-spin:24h
spin kube scaffold --from gitea.lntu.edu.cn/youling/hello-spin:24h --out spinapp.yaml
spin kube scaffold --from gitea.lntu.edu.cn/youling/hello-spin:24h | kubectl apply -f -

# Create Secret in Kubernetes
kubectl create secret registry-credentials ghcr \
    --docker-server gitea.lntu.edu.cn \
    --docker-username $GH_USER \
    --docker-password $CR_PAT

kubectl get secret registry-credentials -o yaml

spin kube scaffold --from gitea.lntu.edu.cn/youling/hello-spin:24h --image-pull-secret registry-credentials

# 部署
spin kube scaffold --from gitea.lntu.edu.cn/youling/spin-js:v1 --autoscaler keda --cpu-limit 100m --memory-limit 128Mi --replicas 3 --max-replicas 10 | kubectl apply -f -
-
# 查看应用
kubectl get spinapps

# 更改引用
spin kube scaffold --from gitea.lntu.edu.cn/youling/spin-js:v1 --replicas 3 | kubectl apply -f -

# 删除应用
kubectl delete spinapp spin-js

#
spin add static-fileserver

spin add kv-explorer -t kv-explorer
